Skip to content

coordinate: address CodeRabbit feedback from #808#809

Merged
phinze merged 1 commit into
mainfrom
phinze/mir-1018-coderabbit-followups
May 14, 2026
Merged

coordinate: address CodeRabbit feedback from #808#809
phinze merged 1 commit into
mainfrom
phinze/mir-1018-coderabbit-followups

Conversation

@phinze
Copy link
Copy Markdown
Contributor

@phinze phinze commented May 14, 2026

Follow-up to #808 (MIR-1018), which got merged before CodeRabbit's review was addressed. Four findings from CR, all valid; this PR works through them.

1. cli/commands/server.go: parse AdditionalIPs before SetupEtcdTLS. The IP set was being handed to coordinate.SetupEtcdTLS() at line 299 with only the discovered IPs in it; explicit cfg.TLS.AdditionalIPs weren't parsed in until ~220 lines later. The etcd server cert SANs would silently omit user-configured addresses, so a distributed runner reaching the cluster over an explicit AdditionalIP would fail TLS verification against etcd. Moved the parse up to right after IP discovery so the set is complete before any cert-issuing code reads it.

2. coordinate.PublicIPs(): route through ComputeAdvertise. This function feeds AutocertController.dnsPointsToUs, so getting it wrong means our ACME provisioning trusts addresses we shouldn't. The pre-refactor version had the same two leaks apiAddresses() had before MIR-1018: it returned resp.SourceAddress even when that family had zero reachable ports, and its fallback admitted 100.64.0.0/10 (CGNAT / Tailscale) through the bare IsGlobalUnicast/IsPrivate check. Routed it through ComputeAdvertise and filtered to candidates classified as global-unicast so both gaps close in one move.

3. debug_advertise: warn-and-continue on ipdiscovery failure. The command was aborting where server.go just warns. That made debug advertise unable to reproduce the very failure mode it exists to diagnose. Mirrored server.go's behavior so it falls through to the explicit-IP and netcheck paths with an empty discovery result.

4. debug_advertise: add --format json. Standard FormatOptions pattern for list-style commands. Useful for piping the candidate decisions into tooling. Suppresses the human progress logs in JSON mode so stdout is parseable; emits a {candidates: [...], advertised: [...]} document. Regenerated the command doc to pick up the new flag.

Verified locally with gotestsum ./components/coordinate (24 tests pass) and make bin/miren && go generate ./... produces no diff after the commit.

  1. server.go: parse cfg.TLS.AdditionalIPs into the IP set BEFORE
     coordinate.SetupEtcdTLS() so the etcd server cert SANs include
     user-configured addresses. Without this, distributed runners
     reaching the cluster over an explicit AdditionalIP would fail
     TLS verification against etcd.

  2. coordinate.PublicIPs(): route through ComputeAdvertise so the
     AutocertController DNS sanity check honors per-family netcheck
     state and the CGNAT filter. Previously this path could leak the
     netcheck source IP even when its family had zero reachable ports,
     and the fallback admitted 100.64.0.0/10 addresses through the
     bare IsGlobalUnicast/IsPrivate check.

  3. debug_advertise: warn-and-continue on ipdiscovery failure
     instead of aborting, mirroring server.go. The whole point of
     the command is to diagnose discovery failure modes, so it
     should still exercise the explicit-IP and netcheck paths
     when interface discovery itself misbehaves.

  4. debug_advertise: add --format json via the FormatOptions
     pattern so the command produces machine-parseable output for
     tooling/automation. Includes regenerated docs for the new flag.

Includes regenerated command docs for debug advertise.
@phinze phinze requested a review from a team as a code owner May 14, 2026 20:23
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b8f00a0c-a707-4fc8-96f0-6e0d77b8af89

📥 Commits

Reviewing files that changed from the base of the PR and between 6d4aea6 and 3ba7d18.

📒 Files selected for processing (4)
  • cli/commands/debug_advertise.go
  • cli/commands/server.go
  • components/coordinate/coordinate.go
  • docs/docs/command/debug-advertise.md

📝 Walkthrough

Walkthrough

This PR refactors IP advertisement and discovery across three functional areas. The server startup moves explicit TLS IP parsing earlier to make those addresses available for certificate SAN configuration. The Coordinator's PublicIPs() method is rewritten to use the shared ComputeAdvertise logic instead of directly querying netcheck state, ensuring consistent filtering and avoiding per-family IP leakage. The debug advertise CLI command adds JSON output support with conditional human logging, allowing structured reporting of candidate classification and final advertised addresses.


Comment @coderabbitai help to get the list of available commands and usage tips.

@phinze
Copy link
Copy Markdown
Contributor Author

phinze commented May 14, 2026

lol I raced a session fixing coderabbit things w/ my own twitchy merge button pushes, and this is what i get

@phinze phinze merged commit 5c05739 into main May 14, 2026
19 checks passed
@phinze phinze deleted the phinze/mir-1018-coderabbit-followups branch May 14, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants